//! Copyright 2012 Xicut Technology, Inc.
//! All rights reserved
//!
#ifndef __SIM900App_h__
#define __SIM900App_h__

#include "BasicTypes.h"
#include "FIFO.h"
#include "Handles.h"
#include "SysTick.h"
#include "SIM900AppCommand.h"

class cSIM900App
{
private:
    enum eSIM900Process
    {
        IDLE,

        INIT_SIM900,
        INIT_CONFIG_REQUEST,
        INIT_SET_BAUDRATE_REQ,

        SEND_ISSUE_PHONE_REQ,
        SEND_ISSUE_PHONE_RPL,
        SEND_ISSUE_MSG_REQ,
        SEND_ISSUE_MSG_RPL,

        INIT_WAIT_OK_RPL,
    };


    static eSIM900Process           s_Process;
    static eSIM900Process           s_SubProcess;
    static cSysTick                 s_ProcessTimeout;
    static cSIM900AppCommand*       s_pSendPendingCmd;
    static cFIFO                    s_SmsReceiveFreeFIFO;
    static U32                      s_SmsReceiveFreeFIFO_Storage[];


public:
    static void InitReset();
    static void RunOne();

private:
    static inline void ResetTimeout(const U32 val)
    {
        s_ProcessTimeout.SetTimeout(val);
        s_ProcessTimeout.ResetTimeBase();
    }
    static bool IsProcessing();
    static void StartSendSms(SIM900AppCommandHandle smsHandle);
    static void TaskProcess();
};

#endif // __SIM900App_h__
